home *** CD-ROM | disk | FTP | other *** search
-
- Docs for COMM.H C communications header file by
-
- Mario Giannini - Compuserve ID: 76276,1576
- New York, New York
-
- Notes:
-
- BUFSIZE is the size of the communications buffer, the default is 8K.
- To change this ad the following line to your main source file:
-
- # define BUFSIZE xxxxx
- Where xxxxx is the size of the buffer in bytes.
-
-
- port - When a port number is required, a 0 specifies COM1 and 1 specifies
- COM2.
-
- Commands:
-
- The folowing functions are defined in COMM.H and can be called once they
- have been combined with your source file using the following line, note that
- functions that do not specify a COM port will use the port for the last
- succesful setintr function.
-
- #include <comm.h>
-
- ------------------------------------------------------------------------
- setintr
-
- summary:
-
- #include <comm.h>
-
- int setintr(port);
- int port; COM port on PC
-
- description:
-
- The setintr function installs the communications interrupt handler for
- the specified COM port. The port is deteremined by the following
- variables:
-
- port COM?:
- ==== =====
- 0 COM1:
- 1 COM2:
-
-
- Returns Value:
-
- setintr returns a 0 if successful, or a -1 if the specified port was
- not found.
-
-
- example:
-
- if (setintr(0))
- printf("Unable to set interrupt\n");
-
- ------------------------------------------------------------------------
- resetint
-
- summary:
-
- void resetint(port);
- int port; COM port on PC
-
- description:
-
- The resetint function will remove the interrupt handler associated with
- the com port specified by port. Care must be taken not to call this
- function if setintr() was not succesful, this might cause the machine
- to lock up under other communications systems.
-
- Return Value:
-
- resetint does not return a value.
-
- example:
-
- resetint(0);
- ------------------------------------------------------------------------
- seravl
-
- summary:
-
- int seravl();
-
- The seravl function resturns a non-zero if there is a character in the
- communications buffer. This function should be called before calling
- the getser function to avoid the buffer table pointers from collision
- (resulting in 1 buffer full of garbage data.
-
- Return Value:
-
- seravl returns a non-zero if a character is available in the com buffer,
- or a zero if not.
-
- example:
-
- if (seravl())
- printf("A character is in the buffer\n");
- ------------------------------------------------------------------------
- getser
-
- summary:
- #include <comm.h>
-
- int getser();
-
- description:
-
- The getser function will get a character from the serial buffer. Make
- sure to check that a character is avaiable with the seravl() function
- before getting it.
-
- Return Value:
-
- getser returns the ASCII value of the next character to be read from the
- com buffer
-
- example:
-
- int ch;
-
- if (seravl())
- {
- ch=getser();
- printf("Character received: %c\n", ch);
- }
- ------------------------------------------------------------------------
- portinit
-
- summary:
- #include <comm.h>
-
- int portinit(port, baud, parity, data, stop);
- int port; com port to initialize
- int baud; baud rate (tested upto 9600)
- int parity; parity: (0=none, 1=odd, 2=even)
- int data; data bits (6-8)
- int stop; stop bits (0-2)
-
- description:
-
- The portinit set the UART chip connect to the COM port specified
- by port to the above mentioned parameters.
-
- return value:
- returns 0 if ok
- -1 if port not there,
- -2 if invalid parameter
-
- example:
-
- if (portinit(0, 1200, 0, 8, 1))
- printf("Error initialising COMM port\n");
- ------------------------------------------------------------------------
- is_carrier
-
- summary:
-
- #include <comm.h>
-
- int is_carrier(port);
-
- int port; com port to check for carrier
-
- description:
-
- The is_carrier function returns a zero if there is no Carrier Detect (CD)
- signal detected at the specified com port, a non-zero otherwise.
-
- example:
-
- if (is_carrier(0))
- printf("Carrier detected at COM1:\n");
- ------------------------------------------------------------------------
- sendstr
-
- summary:
-
- #include <comm.h>
-
- void sendstr(str)
-
- char *str; string to be sent to modem.
-
- description:
-
- The sendstr function allows NULL-terminated strings to be sent to the
- modem. The following characters have a special meaning to sendstr when
- used in the string being sent:
-
- | This character is replaced with a carriage return
-
- ~ This character causes the string to wait 1 second before
- continuing to send the rest of the string. Note: This
- function does not work the same way as the comma in the
- Hayes ATDT command which sends the string and pauses the
- function (dialing) for 2 seconds.
-
-
- Return Value:
-
- sendstr has no return value.
-
- exmaple:
-
- sendstr("||~+++~|ATH|");
-
- The above example will send two CR's to the modem, then wait one
- one second, it will then send a +++, and wait again for 1 second.
- Once that wait is over it sends a CR, ATH, and another CR. This
- sequence will usually work as a software hangup method.
- ------------------------------------------------------------------------
- xmit
-
- summary:
-
- void xmit(ch);
-
- int ch; character to send to COM port.
-
- description:
-
- the xmit function will transmit one character specified by ch out the
- serail port last used by the setintr function.
-
- Return Value:
-
- xmit has no return value.
-
- ------------------------------------------------------------------------
- clr_buf
-
-
- summary:
-
- void clr_buf();
-
- description:
-
- clr_buff clears out all character in the communications buffer.
-
- Return Value:
-
- clr_buf has no return value.
-
- example:
-
- clr_buf();
-
- The buffer was just wiped clear.
- ------------------------------------------------------------------------
- onesec
-
- summary:
-
- #include <comm.h>
-
- void onesec();
-
- description:
-
- This function when called will create a one second time delay. It used
- by the snedstr function and may also prove useful for certain timed file
- transfer protocols.
-
- Return Value:
-
- onesec has no return value.
-
- example:
-
- printf("Please wait one second...");
- onesec();
- printf("Thank you\n");
- ------------------------------------------------------------------------
- hwhangup
-
- summary:
-
- #include <comm.h>
-
- void hwhangup();
-
- description:
-
- The function inverts the signal from the DTR signal out of the COM port
- to perform a hardware hangup for modems that support it.
-
- Return Value:
-
- hwhangup has no return value.
-
- example:
-
- sendstr("Disconnecting from system...");
- hwhangup();
-
- The above example would send the string "Disconnecting from system..." to
- the modem (and through to any users connect) and the hangup the modem
- via the DTR technique.
- ------------------------------------------------------------------------